#include<stdio.h>

void low_four_bit_roll(int a,int bit[])
{
	if(a<0) return;
	int b=15;//00001111低四位
	int i=0,j,temp=a,t[32]={0};
	printf("反转前:%d\n",a);
	while(temp)
	{
		bit[i]=temp%2;
		temp/=2;
		i++;
	}
	
	for(j=32-1;j>=0;j--)
	{
		printf("%d",bit[j]);
		if(j%4==0)
		{
			printf(" ");
		}
	}
	printf("\n");
	int bit_roll=a^b;
	i=0;
	printf("反转后:%d\n",bit_roll);
	while(bit_roll)
	{
		t[i]=bit_roll%2;
		bit_roll/=2;
		i++;
	}
	for(j=32-1;j>=0;j--)
	{
		printf("%d",t[j]);
		if(j%4==0)
		{
			printf(" ");
		}
	}
	printf("\n");
}


int main()
{
	int a;
	int bit[32]={0};
	printf("请输入要将低四位反转的数:\n");
	scanf("%d",&a);
	low_four_bit_roll(a,bit);



	return 0;
}
